package com.xywh.dakaqiandao.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.xywh.dakaqiandao.R;
import com.xywh.dakaqiandao.di.component.DaggerPersonComponent;
import com.xywh.dakaqiandao.di.module.PersonModule;
import com.xywh.dakaqiandao.mvp.contract.PersonContract;
import com.xywh.dakaqiandao.mvp.presenter.PersonPresenter;
import com.xywh.dakaqiandao.mvp.ui.entity.Person;

import java.util.HashMap;

import butterknife.BindView;
import butterknife.OnClick;
import me.jessyan.armscomponent.commonres.utils.CProgressDialogUtils;
import me.jessyan.armscomponent.commonres.utils.ToolbarUtils;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.commonsdk.utils.Utils;

import static com.jess.arms.base.BaseConstants.NICKNAME;
import static com.jess.arms.utils.Preconditions.checkNotNull;


@Route(path = RouterHub.ACTIVITY_PERSON)
public class PersonActivity extends BaseActivity<PersonPresenter> implements PersonContract.View {


    @BindView(R.id.ll_qian_dao_ji_lu)
    LinearLayout llQianDaoJiLu;
    @BindView(R.id.ll_di_qu_she_zhi)
    LinearLayout llDiQuSheZhi;
    @BindView(R.id.ll_ge_ren_gong_zi)
    LinearLayout llGeRenGongZi;
    @BindView(R.id.title)
    TextView title;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerPersonComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .personModule(new PersonModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_person; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        ToolbarUtils.initToolbarTitleBack(this, getString(R.string.activity_person) + "(" + mSharedPreferencesHelper.getString(NICKNAME) + ")");

        //getPersonData();
    }

    @Override
    public void getPersonDataSuccess(Person entityData) {


    }

    private void getPersonData() {
        HashMap<String, String> map = new HashMap<>();

        mPresenter.getPersonData(map);
    }


    @Override
    public void showLoading() {
        CProgressDialogUtils.showProgressDialog(this);
    }

    @Override
    public void hideLoading() {
        CProgressDialogUtils.cancelProgressDialog(this);
    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.makeText(this, message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }


    @OnClick({R.id.ll_qian_dao_ji_lu, R.id.ll_di_qu_she_zhi, R.id.ll_ge_ren_gong_zi})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_qian_dao_ji_lu:
                Utils.navigation(this, RouterHub.ACTIVITY_QIAN_DAO_JI_LU_LIE_BIAO);
                break;
            case R.id.ll_di_qu_she_zhi:
                Utils.navigation(this, RouterHub.ACTIVITY_DI_QU_SHE_ZHI);

                break;
            case R.id.ll_ge_ren_gong_zi:
                Utils.navigation(this, RouterHub.ACTIVITY_MY_SALARY);
                break;
        }
    }


}
